package com.dubbo.passport.controller;

import com.dubbo.passport.service.PassportService;
import com.dubbo.pojo.Users;
import com.sun.org.apache.regexp.internal.RE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
public class PassprotController {
    @Autowired
    private PassportService passportService;
    @RequestMapping("/login")
    public String login(Users user, HttpSession session){
        Users users = passportService.login(user);
        /*System.out.println("passController:"+users);*/
        if (users != null){
            session.setAttribute("user",users);
            return "redirect:/success";
        }
        return "fail";
    }

    @RequestMapping("/exit")
    public String exit(HttpSession session){
        session.invalidate();
        return "loginuser";
    }

}
